package com.zj.sy.controller;

import com.alibaba.fastjson.JSONObject;
import com.zj.sy.api.ApiResult;
import com.zj.sy.service.DotDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;

@RestController
@RequestMapping("/dotData")
public class DotDataController {
    @Autowired
    private DotDataService dotDataService;

//打点后台服务
    @GetMapping("/Q")
    public Object getDataDot(@RequestParam(required = false) String DBTAG,String xkey,String key) {

        JSONObject r = new JSONObject();
        r.put("message", "成功!");
        r.put("status", "true");
        r.put("timestamp", LocalDateTime.now());
        r.put("traceId", "");
        r.put("code", "00000");

        r.put("data", dotDataService.getDataDot());


        return r;
    }

    @GetMapping("/getById")
    public Object getById(@RequestParam Long id, @RequestParam String type) {

        JSONObject r = new JSONObject();
        r.put("message", "成功!");
        r.put("status", "true");
        r.put("timestamp", LocalDateTime.now());
        r.put("traceId", "");
        r.put("code", "00000");

        r.put("data", dotDataService.getById(id, type));


        return r;
    }


}
